import React, { Component } from 'react';
import { connect } from 'dva';

import './styles.less';

class Main extends Component {
  state = {
    
  }
  componentDidMount() {
    this.data = localStorage.getItem('data') ? JSON.parse(localStorage.getItem('data')) : {};
    const { history } = this.props;
    if (!this.data.name) {
      history.push({
        pathname: '/login',
      });
    }
  }
  render() {
    const { data = {} } = this;
    console.log(data)
    return (
      <div className="main-pages">
        <div className="merchant-cell">
          <div className="item">
            <span className="label">商家名称：</span>
            <span className="value">{data.name || ''}</span>
          </div>
          <div className="item">
            <span className="label">商家ID：</span>
            <span className="value">{data.no || ''}</span>
          </div>
          <div className="item">
            <span className="label">联系人姓名：</span>
            <span className="value">{data.contactName || ''}</span>
          </div>
          <div className="item">
            <span className="label">联系人手机号：</span>
            <span className="value">{data.contactMobile || ''}</span>
          </div>
          {/* <div className="item">
            <span className="label">余额：</span>
            <span className="value">{data.balance || ''}</span>
          </div> */}
          <div className="item">
            <span className="label">收费类型：</span>
            <span className="value">{data.feeType != 'advance' ? '后付费' : '预付费'}</span>
          </div>
          {
            data.feeType == 'advance' ?
              <div className="item">
                <span className="label">金额：</span>
                <span className="value">{data.balance || '0.00'}元</span>
              </div> : null
          }
        </div>
      </div>
    );
  }
}


export default connect((state) => {
  return {
    order: state.order,
  };
})(Main);
